<div class="form">

	<?php
	$properties = array(
		'id'=>'member-date-form',
		'enableAjaxValidation'=>false,
	);
	$form = $this->beginWidget('CActiveForm', $properties);
	?>

	<p class="note">
		Fields with <span class="required">*</span> are required.
	</p>

	<?php
	echo $form->errorSummary($model);
	$builtin = array_search($model->name, $model->nameList) !== false;
	?>

	<?php if (!$builtin): ?>
		<div class="row">
			<?php
			echo $form->labelEx($model, 'name');
			$htmlOptions = array('size'=>60, 'maxlength'=>255, 'class'=>'fill');
			$properties = array(
				'model'=>$model,
				'attribute'=>'name',
				'source'=>$model->nameList,
				'options'=>array(
					'minLength'=>'1',
				),
				'htmlOptions'=>$htmlOptions,
			);
			$this->widget('zii.widgets.jui.CJuiAutoComplete', $properties);
			echo $form->error($model, 'name');
			?>
		</div>
	<?php endif; ?>

	<div class="row">
		<?php
		$name = Chtml::activeName($model, 'value');
		$id = Chtml::activeId($model, 'value');
		if ($builtin) {
			echo CHtml::label($model->name, $id, array('required'=>true));
		} else {
			echo $form->labelEx($model, 'value');
		}
		$value = $model->value ? date('Y-m-d', $model->value) : '';
		$properties = array(
			'name'=>$name,
			'id'=>$id,
			'value'=>$value,
			'options'=>array(
				'showAnim'=>'fold',
				'dateFormat'=>'yy-mm-dd',
				'changeMonth'=>true,
				'changeYear'=>true,
				'yearRange'=>'1930:' . date('Y', time()),
			),
		);
		$this->widget('zii.widgets.jui.CJuiDatePicker', $properties);
		echo $form->error($model, 'value');
		?>
	</div>

	<div class="row buttons">
		<?php
		echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
		?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->